<form class="layui-form layui-box" style='padding:25px 30px 20px 0' action="/admin/user/edit" data-auto="true" method="post">

    <div class="layui-form-item">
        <label class="layui-form-label">用户账号</label>
        <div class="layui-input-block">
            {% if user.username %}
            <input readonly="readonly" disabled="disabled" name="username" value='{{ user.username|default('')}}'
                   required="required" title="请输入用户名称" placeholder="请输入用户名称" class="layui-input layui-disabled">
            {% else %}
            <input autofocus name="username" value='{{ user.username|default("")}}' required="required" pattern="^.{4,}$"
                   title="请输入用户名称" placeholder="请输入4位及以上字符用户名称" class="layui-input">
            {% endif %}
        </div>
    </div>

    {% if user.username %}
    {% else %}
    <div class="layui-form-item">
        <label class="layui-form-label">用户密码</label>
        <div class="layui-input-block">
            <input name="password" type="password" value='{{ user.password|default("") }}'  pattern="^\S{1,}$" required="" 
                title="请输入密码" placeholder="请输入密码" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">确认密码</label>
        <div class="layui-input-block">
            <input type="password" name="repassword" value='' pattern="^\S{1,}$" required="" title="请输入重复密码"
                title="请输入密码" placeholder="请输入重复密码" class="layui-input">
        </div>
    </div>
    {% endif %}

    <div class="layui-form-item">
        <label class="layui-form-label">联系手机</label>
        <div class="layui-input-block">
            <input type="tel" name="mobile" value='{{ user.mobile|default("") }}' pattern="^1[3-9][0-9]{9}$"
                   title="请输入联系手机" placeholder="请输入联系手机" class="layui-input">
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">联系邮箱</label>
        <div class="layui-input-block">
            <input name="email" pattern="^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$"
                   value='{{ user.email|default("") }}' title="请输入联系邮箱" placeholder="请输入联系邮箱" class="layui-input">
        </div>
    </div>

    
    <div class="layui-form-item">
        <label class="layui-form-label">是否管理员</label>
        <div class="layui-input-block">
            <label class="think-radio">
                <input checked type="radio" name="is_admin" value="1" title="是" lay-ignore> 是
            </label>
            <label class="think-radio">
                <input type="radio" name="is_admin" value="0" title="否" lay-ignore> 否
            </label>
        </div>
    </div>

    {% if authorizes %}
    <div class="layui-form-item">
        <label class="layui-form-label">访问授权</label>
        <div class="layui-input-block">
            {% for authorize in authorizes %}
            {% if user.groupid === authorize.id %}
            <label class="think-checkbox">
                <input type="checkbox" checked name="authorize" value="{{authorize.id}}" lay-ignore> {{authorize.desc}}
            </label>
            {% else %}
            <label class="think-checkbox">
                <input type="checkbox" name="authorize" value="{{authorize.id}}" lay-ignore> {{authorize.desc}}
            </label>
            {% endif %}
            {% else %}
            <span class="color-desc" style="line-height:36px">未配置权限</span>
            {% endfor %}
        </div>
    </div>
    {% endif %}

    <div class="layui-form-item">
        <label class="layui-form-label">用户描述</label>
        <div class="layui-input-block">
            <textarea placeholder="请输入用户描述" title="请输入用户描述" class="layui-textarea"
                      name="desc">{{ user.desc|default("") }}</textarea>
        </div>
    </div>

    <div class="hr-line-dashed"></div>

    <div class="layui-form-item text-center">
        {% if user.id %}<input type='hidden' value='{{user.id}}' name='id'/>{% endif %}
        <button class="layui-btn" type='submit'>保存数据</button>
        <button class="layui-btn layui-btn-danger" type='button' data-confirm="确定要取消编辑吗？" data-close>取消编辑</button>
    </div>
    <script>window.form.render();</script>
</form>
